using Circus.CodeEditor;
using System;
using System.ComponentModel;
namespace Circus.Syntax.CodeCompletion
{
	public class CodeSnippet : IComparable
	{
		private ICodeSnippetHeader header = new CodeSnippetHeader();
		private ICodeSnippetDeclarations declarations = new CodeSnippetDeclarations();
		private ICodeSnippetImports imports = new CodeSnippetImports();
		private ICodeSnippetReferences references = new CodeSnippetReferences();
		private ICodeSnippetCode code = new CodeSnippetCode();
		private int imageIndex = -1;
		private object customData;
		private CodeSnippets parent;
		public virtual ICodeSnippetHeader Header
		{
			get
			{
				return this.header;
			}
			set
			{
				if (this.header != value)
				{
					this.header = value;
					this.OnHeaderChanged();
				}
			}
		}
		public virtual ICodeSnippetDeclarations Declarations
		{
			get
			{
				return this.declarations;
			}
		}
		public virtual ICodeSnippetImports Imports
		{
			get
			{
				return this.imports;
			}
		}
		public virtual ICodeSnippetReferences References
		{
			get
			{
				return this.references;
			}
		}
		public virtual ICodeSnippetCode Code
		{
			get
			{
				return this.code;
			}
			set
			{
				if (this.code != value)
				{
					this.code = value;
					this.OnCodeChanged();
				}
			}
		}
		public virtual string Description
		{
			get
			{
				string text = this.header.Description;
				if (this.header.Shortcut != null && this.header.Shortcut != string.Empty)
				{
					text = text + ((this.parent != null && this.parent.UseHtmlFormatting) ? SyntaxConsts.DefaultBrTag : "\r\n") + string.Format(StringConsts.CodeSnippetTooltipHeader, this.header.Shortcut);
				}
				return text.Trim();
			}
		}
		public virtual int ImageIndex
		{
			get
			{
				return this.imageIndex;
			}
			set
			{
				if (this.imageIndex != value)
				{
					this.imageIndex = value;
					this.OnImageIndexChanged();
				}
			}
		}
		public virtual object CustomData
		{
			get
			{
				return this.customData;
			}
			set
			{
				if (this.customData != value)
				{
					this.customData = value;
					this.OnCustomDataChanged();
				}
			}
		}
		public virtual CodeSnippets Parent
		{
			get
			{
				return this.parent;
			}
			set
			{
				if (this.parent != value)
				{
					this.parent = value;
					this.OnParentChanged();
				}
			}
		}
	
		protected virtual void OnHeaderChanged()
		{
		}
		protected virtual void OnCodeChanged()
		{
		}
		protected virtual void OnImageIndexChanged()
		{
		}
		protected virtual void OnCustomDataChanged()
		{
		}
		protected virtual void OnParentChanged()
		{
		}
		public CodeSnippet()
		{
		}
		public CodeSnippet(CodeSnippets parent) : this()
		{
			this.parent = parent;
		}
		protected virtual void OnSnippetDeclarationsChanged()
		{
		}
		protected virtual void OnSnippetImportsChanged()
		{
		}
		protected virtual void OnSnippetReferencesChanged()
		{
		}
		public virtual int CompareTo(object value)
		{
			if (value is CodeSnippet)
			{
				return string.Compare(this.Header.Title, ((CodeSnippet)value).Header.Title, true);
			}
			throw new ArgumentException();
		}
	}
}
